<template>
	<scroll-view scroll-y="true" style="height: 100vh;" @scrolltolower="loadmore">
			<view class="pagebody">
				<view class="prizetitle">{{drawtitle}}</view>
				<view class="prizeitem" v-for="(item,index) in listdata" :key="index">
					<image :src="item.avatar" mode="aspectFill"></image>
					<text>{{item.nickname}}</text> 
				</view>
			</view>
			<empty v-if="lock"></empty>
	</scroll-view>

</template>

<script>
	/**
	 * 更多中奖名单
	 */
	export default{
		data(){
			return{
				listdata:[],
				drawtitle:'',
				dreawlevel:['一等奖名单','二等奖名单','三等奖名单'],
				luckid:'',//中奖id
				level:'',
				page:1,
				lock:false,
				
			}
		},
		onLoad(option){
			console.log(option)
			this.luckid = option.dreawid;
			this.drawtitle = option.drawtitle;
			this.level = option.level;
			uni.setNavigationBarTitle({
				title: this.dreawlevel[option.level]
			})
			//初次加载
			this.initinfo(option.dreawid,option.level)
		},
		methods:{
			loadmore(){
				if(this.lock) return
				this.page +=1; 
				this.initinfo(this.luckid,this.level,this.page);
			},
			
			
			initinfo(id,levels,page=1){
				console.log(id,page);
				this.$HttRequest({
					url: '/lottery/winList',
					param: {
						id:id,
						index:levels,
						page:page,
						}
				},'GET',true).then((res) => {
					console.log(res);
					if (res.status === 10000) {
			
						let rescoures = res.data.list.data
						if(!rescoures.length){
							this.lock = true;
						}
						this.listdata = this.listdata.concat(rescoures);
					} else {
						this.$ShowMsg(res.message)
					}
				}).catch((error) => {
					//异常错误
					this.$ShowMsg('statusCode：' + error.errMsg);
				});
				
			}
			
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f0f0f0;
	}
	.pagebody{
		margin: 20rpx;
		border-radius: 20rpx;
		flex: 1;
		background-color: #fff;
		
	}
	
	.prizeitem{
		width: 100%;
		font-size: 32rpx;
		height: 120rpx;
			border-top: 1rpx solid #e1e1e1;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			image{
				border-radius: 50%;
				height: 85rpx;
				width: 85rpx;
				margin: 0 30rpx;
				margin-right: 20rpx;
			}
	}
	.prizetitle{
		display: flex;
		align-items: center;
		justify-content: flex-start;
		width: 100%;
		height: 100rpx;
		font-size: 36rpx;
		font-weight: bold;
		padding-left: 30rpx;
	}
</style>
